package com.tcode.springjpa.services;

import com.tcode.springjpa.bean.Userbean;
import com.tcode.springjpa.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;
import java.util.Optional;

@Service
public class UserServer {

    @Autowired
    private UserDao ud;

    public Userbean findUserByID(int id){
        return ud.findById(id).get();
    }
    public List<Userbean> findAllUser(){
        return ud.findAll();
    }
    public void insertUser(Userbean user){
        ud.save(user);
    }
    public void updateUser(Userbean user){
        ud.modUser(user.getUname(),user.getPhone(),user.getUid());
    }

    public void deletaUser(int id){
        ud.deleteById(id);
    }
}
